function request(url, params, methods, success, fail) {
    this.requestLoading(url, params, "", success, fail)
  }
  function requestLoading(url, params, methods, message, success, fail) {
    wx.showNavigationBarLoading()
    if (message != "") {
      wx.showLoading({
        title: message,
      })
    }
    const baseURL = process.env.API_BASE_URL
    wx.request({
      url: `${baseURL}/`+url,
      data: params,
      header: {
        'Content-Type': 'application/json'
      },
      method: methods,
      success: function (res) {
        wx.hideNavigationBarLoading()
        if (message != "") {
          wx.hideLoading()
        }
        if (res.statusCode == 200) {
          success(res.data)
        } else {
          fail()
        }
      },
      fail: function (res) {
        wx.hideNavigationBarLoading()
        if (message != "") {
          wx.hideLoading()
        }
        fail()
      },
      complete: function (res) {
   
      },
    })
  }
module.exports = {
    request: request,
    requestLoading: requestLoading
}